﻿#pragma once

//////////////////////////////////////////////////////////
//	CRealTimeChromG
//	谱图显示控件  三条曲线或两条同时显示
//	可实时，也可以显示历史
//	2021-11-11
// CRealTimeChromG

class CRealTimeChromG : public CWnd
{
	DECLARE_DYNAMIC(CRealTimeChromG)

public:
	CRealTimeChromG();
	virtual ~CRealTimeChromG();
private:
	CRect	m_rcArea;
	CFont   font;
	long	m_nMaxYA;		//坐标轴的刻度设置  组爷爷奶奶
	long	m_nMaxYB;		//全烃
	long	m_nMinYA;
	long	m_nMinYB;
	long	m_nXScale;

	int		m_nTimer;
	CTime	m_tOld;			//上一次分析的时间
	int		m_nTicks;

public:
	void	FindMinMax();
	void	RefreshGraph();

	//缩放操作
private:
	bool	m_bMouseDown;
	int		m_nZoomMode;			//缩放状态 0--正常，1--缩放，2--拖动
	CPoint		c_ptDown;			// 鼠标按下时点的坐标
	CPoint		c_ptLast;			// 鼠标移动过程中最后一点坐标

	void	DrawDynamicRect(CDC *pDC, CPoint ptBegin, CPoint ptOld, CPoint ptNew);
	void	CaculateZoom(CPoint ptBegin, CPoint ptEnd);
	float	GetPointY(CPoint pt, int nYIndex);

private:
	void	DrawFrame(CRect rt, CDC *pDC);
	void	DrawCurve(CRect rt, CDC *pDC);
	void	Draw(CDC* pDC, CRect rt);

protected:
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnPaint();
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnTimer(UINT_PTR nIDEvent);
};


